﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Model.Items;
using Model.Hero;
using RemotingInterfaces;

namespace Model.Adventure
{   
    public abstract class NPC : Character
    {
        //NPC's have no items equipped, but simply an attack/defense rating     
        protected List<Item> _loot;        

        protected double _vitality_health_multiplier = 2.5;

        public NPC(String race)
            : base(race)
        {
            _attack_rating = 5;
            _defense_rating = 5;                   
        }

        public int Attack_Rating
        {            
            get { return (int)(_attack_rating + 2.0 * Strength); }
        }

        public int Defense_Rating
        {           
            get { return (int)(_defense_rating + 2.0 * Agility); }
        }

        public int Health
        {
            get { return (int)Math.Floor(Vitality * _vitality_health_multiplier * _level * 0.5); }
        }

        //computes the total value of all loot on the NPC
        public int LootValue()
        {
            return 0;
        }

        //computes the total maximum value of loot given by killing the NPC in gold
        public long MaxLootValue()
        {
            //currently a simple calculation based on lvl, given exponential amount of gold with increasing lvl
            //Console.WriteLine("Exponent: " + 3.0 * Math.Log(_level, 2.00));
            //OK balanced atm. 300 mill at lvl 99, 90 mill at lvl 75, 15 mill at lvl 50, 1 mill at lvl 27, 300k at lvl 20
            return (long)(Math.Exp(3.0 * Math.Log(_level, 2.00)) * (1 - Math.Min(15, _level) * 0.02) + 15 * _level);
        }

        public long XP_Value
        {
            get
            {
                return Level * 20;
            }
        }



        public override String ToString()
        {
            String str =
                    base.ToString() +        
                   "Attack Rating: " + Attack_Rating + "\n" +
                   "Defense Rating: " + Defense_Rating + "\n" +
                   "Health: " + Health + "\n" +
                   "Current health: " + CurrentHealth + "\n";            
            return str;
        }
    }    
}
